import { api } from '../../../config/api';
import { request } from '../../../utils/request';
Page({
  data: {
    loading: false,
    nameValue: '',
  },
  onLoad(options) {
    const { name } = options;
    this.setData({
      nameValue: name,
    });
  },
  onSubmit() {
    wx.showLoading({
			title: '处理中',
			mask: true,
		});
    let me = this;
    me.setData({loading: true});
    request.post(api.user.edit, { nickName: this.data.nameValue })
      .then(res => {
        wx.hideLoading();
        me.setData({loading: false});
        wx.navigateBack({ backRefresh: true });
      });
  },
  clearContent() {
    this.setData({
      nameValue: '',
    });
  },
});
